package com.ccc.boot.generator.response;

import java.util.List;
import java.util.Map;

/**
 * 封装返回结果
 *
 * @author superC
 * @date 2022/3/29
 * @version 0.1.0
 */

public class TableResultResponse<T> extends BaseResponse {

    TableData<T> data;

    Map<String, Object> fieldInfoMap;

    public TableResultResponse(long total, List<T> records) {
        this.data = new TableData<T>(total, records);
    }

    public TableResultResponse() {
        this.data = new TableData<T>();
    }

    TableResultResponse<T> total(int total) {
        this.data.setTotal(total);
        return this;
    }

    TableResultResponse<T> total(List<T> records) {
        this.data.setRecords(records);
        return this;
    }

    class TableData<T> {
        long total;
        List<T> records;

        public TableData(long total, List<T> records) {
            this.total = total;
            this.records = records;
        }

        public TableData() {
        }

        public long getTotal() {
            return total;
        }

        public void setTotal(long total) {
            this.total = total;
        }

        public List<T> getRecords() {
            return records;
        }

        public void setRecords(List<T> records) {
            this.records = records;
        }
    }

    public TableData<T> getData() {
        return data;
    }

    public void setData(TableData<T> data) {
        this.data = data;
    }

    public Map<String, Object> getFieldInfoMap() {
        return fieldInfoMap;
    }

    public void setFieldInfoMap(Map<String, Object> fieldInfoMap) {
        this.fieldInfoMap = fieldInfoMap;
    }
}

